/**
 * <copyright>
 * </copyright>
 *
 * $Id$
 */
package model.impl;

import model.Episode;
import model.EpisodesPackEpisode;
import model.ModelPackage;

import org.eclipse.emf.common.notify.Notification;
import org.eclipse.emf.common.notify.NotificationChain;

import org.eclipse.emf.ecore.EClass;
import org.eclipse.emf.ecore.InternalEObject;

import org.eclipse.emf.ecore.impl.ENotificationImpl;
import org.eclipse.emf.ecore.impl.EObjectImpl;

/**
 * <!-- begin-user-doc -->
 * An implementation of the model object '<em><b>Episodes Pack Episode</b></em>'.
 * <!-- end-user-doc -->
 * <p>
 * The following features are implemented:
 * <ul>
 *   <li>{@link model.impl.EpisodesPackEpisodeImpl#getEpisode <em>Episode</em>}</li>
 * </ul>
 * </p>
 *
 * @generated
 */
public class EpisodesPackEpisodeImpl extends AggregationImpl implements EpisodesPackEpisode {
	/**
	 * The cached value of the '{@link #getEpisode() <em>Episode</em>}' reference.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @see #getEpisode()
	 * @generated
	 * @ordered
	 */
	protected Episode episode;

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	protected EpisodesPackEpisodeImpl() {
		super();
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@Override
	protected EClass eStaticClass() {
		return ModelPackage.Literals.EPISODES_PACK_EPISODE;
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public Episode getEpisode() {
		if (episode != null && episode.eIsProxy()) {
			InternalEObject oldEpisode = (InternalEObject)episode;
			episode = (Episode)eResolveProxy(oldEpisode);
			if (episode != oldEpisode) {
				if (eNotificationRequired())
					eNotify(new ENotificationImpl(this, Notification.RESOLVE, ModelPackage.EPISODES_PACK_EPISODE__EPISODE, oldEpisode, episode));
			}
		}
		return episode;
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public Episode basicGetEpisode() {
		return episode;
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public NotificationChain basicSetEpisode(Episode newEpisode, NotificationChain msgs) {
		Episode oldEpisode = episode;
		episode = newEpisode;
		if (eNotificationRequired()) {
			ENotificationImpl notification = new ENotificationImpl(this, Notification.SET, ModelPackage.EPISODES_PACK_EPISODE__EPISODE, oldEpisode, newEpisode);
			if (msgs == null) msgs = notification; else msgs.add(notification);
		}
		return msgs;
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public void setEpisode(Episode newEpisode) {
		if (newEpisode != episode) {
			NotificationChain msgs = null;
			if (episode != null)
				msgs = ((InternalEObject)episode).eInverseRemove(this, ModelPackage.EPISODE__EPISODES_PACK_EPISODE, Episode.class, msgs);
			if (newEpisode != null)
				msgs = ((InternalEObject)newEpisode).eInverseAdd(this, ModelPackage.EPISODE__EPISODES_PACK_EPISODE, Episode.class, msgs);
			msgs = basicSetEpisode(newEpisode, msgs);
			if (msgs != null) msgs.dispatch();
		}
		else if (eNotificationRequired())
			eNotify(new ENotificationImpl(this, Notification.SET, ModelPackage.EPISODES_PACK_EPISODE__EPISODE, newEpisode, newEpisode));
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@Override
	public NotificationChain eInverseAdd(InternalEObject otherEnd, int featureID, NotificationChain msgs) {
		switch (featureID) {
			case ModelPackage.EPISODES_PACK_EPISODE__EPISODE:
				if (episode != null)
					msgs = ((InternalEObject)episode).eInverseRemove(this, ModelPackage.EPISODE__EPISODES_PACK_EPISODE, Episode.class, msgs);
				return basicSetEpisode((Episode)otherEnd, msgs);
		}
		return super.eInverseAdd(otherEnd, featureID, msgs);
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@Override
	public NotificationChain eInverseRemove(InternalEObject otherEnd, int featureID, NotificationChain msgs) {
		switch (featureID) {
			case ModelPackage.EPISODES_PACK_EPISODE__EPISODE:
				return basicSetEpisode(null, msgs);
		}
		return super.eInverseRemove(otherEnd, featureID, msgs);
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@Override
	public Object eGet(int featureID, boolean resolve, boolean coreType) {
		switch (featureID) {
			case ModelPackage.EPISODES_PACK_EPISODE__EPISODE:
				if (resolve) return getEpisode();
				return basicGetEpisode();
		}
		return super.eGet(featureID, resolve, coreType);
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@Override
	public void eSet(int featureID, Object newValue) {
		switch (featureID) {
			case ModelPackage.EPISODES_PACK_EPISODE__EPISODE:
				setEpisode((Episode)newValue);
				return;
		}
		super.eSet(featureID, newValue);
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@Override
	public void eUnset(int featureID) {
		switch (featureID) {
			case ModelPackage.EPISODES_PACK_EPISODE__EPISODE:
				setEpisode((Episode)null);
				return;
		}
		super.eUnset(featureID);
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@Override
	public boolean eIsSet(int featureID) {
		switch (featureID) {
			case ModelPackage.EPISODES_PACK_EPISODE__EPISODE:
				return episode != null;
		}
		return super.eIsSet(featureID);
	}

} //EpisodesPackEpisodeImpl
